#define  _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    int lengthOfLongestSubstring(string s) {
        int l = 0, r = 0, ret = 0;
        int hash[256]{};
        int n = s.size();
        while (r < n)
        {
            hash[s[r]]++;
            while (hash[s[r]] > 1)
            {
                hash[s[l]]--;
                l++;
            }
            r++;
            ret = max(ret, r - l);
        }
        return ret;
    }
};